<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="renderer" content="webkit|ie-comp|ie-stand">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
		<meta http-equiv="Cache-Control" content="no-siteapp" />
		<link rel="Bookmark" href="/favicon.ico">
		<link rel="Shortcut Icon" href="/favicon.ico" />
		<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5shiv.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<![endif]-->
		<link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
		<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css" />
		<link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css" />
		<link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin" />
		<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css" />
		<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
		<!--/meta 作为公共模版分离出去-->

		<title>封条分发 - 胆款流转实时监控管理系统 v1.0</title>
		<meta name="keywords" content="胆款流转实时监控管理系统 v1.0">
		<meta name="description" content="胆款流转实时监控管理系统 v1.0">
	</head>

	<body>
		<article class="page-container">
			<!-- <form action="/apis/base/cashbox/createCashbox" method="post" class="form form-horizontal" id="form-pocketTag-edit"> -->
			<form action="http://localhost:8000/cashbox/createCashboxsByCashboxIdRange" method="post" class="form form-horizontal" id="form-pocketTag-edit">
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3">封条号码：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<textarea id="codes" class="textarea" disabled="disabled"></textarea>
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3">分公司：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input style="width: 60%;" class="input-text" readonly="readonly" id="comId"/>
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3">票务室：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<span class="select-box">
							<select class="select" id="toId" name="toId">
							</select>
						</span>
					</div>
				</div>
				

				<div class="row cl">
					<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
						<input id="submit_btn" class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
					</div>
				</div>
			</form>
		</article>

		<!--_footer 作为公共模版分离出去-->
		<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
		<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
		<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script>
		<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script>
		<!--/_footer 作为公共模版分离出去-->

		<!--请在下方写此页面业务相关的脚本-->
		<script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script>
		<script type="text/javascript" src="lib/jquery.validation/1.14.0/jquery.validate.js"></script>
		<script type="text/javascript" src="lib/jquery.validation/1.14.0/validate-methods.js"></script>
		<script type="text/javascript" src="js/jquery.base64.js"></script>
		<script type="text/javascript">
			$(function() {
				var codes = localStorage.getItem("codes");
				var ids = localStorage.getItem("ids");
				console.log(codes+"-"+ids);
				$("#codes").val(codes);
				$('.skin-minimal input').iCheck({
					checkboxClass: 'icheckbox-blue',
					radioClass: 'iradio-blue',
					increaseArea: '20%'
				});
				var userinfo = getUserInfo();
				var userid = userinfo.username;
				var comname = userinfo.company.companyname;
				var comid = userinfo.company.companyid;
				console.log("=============="+comname);
				$("#comId").val(comname);
				var myDate = new Date().Format("yyyy-MM-dd HH:mm:ss");
				var outtime = myDate.toLocaleString();
				console.log(outtime);
				$.ajax({
					type: 'get',
					url: report_service+'/getTicktOfficeByCom',
					/* beforeSend: function (request) {
									request.setRequestHeader("Authorization", "Bearer " + getToken());
								}, */
					data:{
						"comId":comid
					},
					cache:false,    
					dataType:'json',
					async: false,
					success: function(data){
						//var list = data.list;
						var list =  eval('(' + data.list + ')');
						for(var i=0;i<list.length;i++){
							var option = '<option value="'+list[i].toiid+'">'+list[i].toiname+'</option>';
							$("#toId").append(option);
						}
					},
					error:function(){
						alert("请求失败");
					}
				});
				
				$("#form-pocketTag-edit").validate({
					rules: {},
					onkeyup: false,
					focusCleanup: true,
					success: "valid",
					submitHandler: function(form) {
						if($("#comId").val() == '') {
							alert("请使用分公司管理员用户登录！")
							return;
						}
						
						var type = $('input:radio:checked').val();
						var toId = $("#toId").val();
						var mydate = new Date();
						var year = mydate.getFullYear();
						
						if(toId.indexOf(1)!=0){
							alert("请使用分公司管理员用户登录！")
							return;
						}
						
						
						console.log(comid+"-"+userid+"-"+ids+"-"+"-"+type);
						
						
						$.ajax({
							type: 'post',
							url: report_service + "/editPocketTagByOne",
							data: {
								'outtime': outtime,
								'outuser': userid,
								'comid': comid,
								'toId': toId,
								'ids': ids
							},
							cache: false,
							beforeSend: function(request) {
								request.setRequestHeader("Authorization", "Bearer " + getToken());
							},
							dataType: 'json',
							success: function(data) {
								console.log("返回的数据：" + data.updateNum);
								if(data != null) {
									var index = parent.layer.getFrameIndex(window.name);
									parent.$('.btn-refresh').click();
									parent.layer.close(index);
								} else {
									alert("提交失败，请检查起止号封条是否存在再重新提交！")
								}
							},
							error: function() {
								alert("请求失败,请联系管理员解决！");
							}
						});

					}
				});
			});
			//获取当前时间
			Date.prototype.Format = function (fmt) {
				var o = {
					"M+": this.getMonth() + 1, //月份
					"d+": this.getDate(), //日
					"H+": this.getHours(), //小时
					"m+": this.getMinutes(), //分
					"s+": this.getSeconds(), //秒
					"q+": Math.floor((this.getMonth() + 3) / 3), //季度
					"S": this.getMilliseconds() //毫秒
				};
				if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
				for (var k in o)
				if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
				return fmt;
			}
		</script>
		<!--/请在上方写此页面业务相关的脚本-->
	</body>

</html>